<template>
  <div class="withdrawal">
    <div class="content">
      	<div class="area">
						<div class="mod">
							<dl>
								<dt>可提现收益</dt>
								<dd><span>{{avail_income}}</span><a href="javascript:;" @click="withdraw" class="btn_ashy_tx">申请提现</a></dd>
							</dl>
						</div>
						<!-- <a href="javascript:;" class="more">查看提现记录</a> -->
            <router-link :to="{path:'/accountMessage/withdrawalRecord',query:{type:2,account:3}}" class="more">查看提现记录</router-link>
				</div>
        <div class="area"> 
						<div class="attention">
							<h5>注意事项</h5>
							<dl>
								<dt>1.对公提现：</dt>
								<dd>开发者提现--寄增值税专用发票至我司--财务收到发票审核后2个工作日内打款
									发票内容：“信息技术服务费”</dd>
								<dd>
									<p>开票信息 </p>
									<p>名称：杭州明楚科技有限公司 </p>
									<p>税号：91330103571459763B </p>
									<p>地址电话：杭州市下城区绍兴路347号华洲创业大楼1号楼218室 0571-89936492 </p>
									<p>银行及账号：工行高新支行 1202026209900178949 </p>
								</dd>
								<dd>
									<p>收货地址：杭州市下城区绍兴路347号华洲创业大楼1号楼218室 </p>
									<p>收件人：徐萍 </p>
									<p>电话：13805738581 </p>
								</dd>
							</dl>
							<dl>
								<dt>2. 个人提现</dt>
								<dd>个人开发者提现需按国家税法规定，由我司代扣代缴个人所得税 </dd>
								<dd>发放方式：自然月内可以多次提现申请，公司于次月10日以前一次性扣除所得税额后打入开发者银行账户，即实际提现金额为税后金额，个人开发者提现前需提交收款人身份证扫描件及联系电话。 </dd>
							</dl>
						</div>
					</div>
    </div>
  </div>
</template>
<script>
import commonJs from "@/common/js/common";
export default {
  name: "withdrawal",
  data() {
    return {
      type: 2,
      account: 3,
      avail_income: 0
    };
  },
  mounted() {
    this.devId = localStorage.getItem("devId");
    this.token = localStorage.getItem("token");
    this.initData();
  },
  methods: {
    //可提现收益
    initData() {
      this.$http({
        method: "POST",
        url: commonJs.BASE_URL + "/account/loadAccountMoney.do",
        data: `devId=${this.devId}&token=${this.token}`
      })
        .then(res => {
          if (res.data.code == 0) {
            this.avail_income = res.data.data.avail_income;
          } else {
            this.$message({
              type: "warning",
              message: res.data.message
            });
          }
        })
        .catch(error => {
          this.$message({
            type: "warning",
            message: "网络错误，请稍后再试！"
          });
        });
    },
    withdraw() {
      if (this.avail_income <= 0) {
        this.$message({
          type: "warning",
          message: "你的可提现金额为0！"
        });
        return;
      }
      this.$prompt("请输入提现金额", "提现", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        inputPattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
        inputErrorMessage: "提现金额格式不正确"
      })
        .then(({ value }) => {
          if (value > this.avail_income) {
            this.$message({
              type: "warning",
              message: "你的提现大于可提现金额！"
            });
            return;
          }
          this.$http({
            method: "POST",
            url: commonJs.BASE_URL + "/account/withdrawal.do",
            data: `devId=${this.devId}&token=${this.token}&applyMoney=${value}`
          }).then(res => {
            if (res.data.code == 0) {
              this.initData();
              this.$message({
                type: "success",
                message: res.data.message
              });
            } else {
              this.$message({
                type: "warning",
                message: res.data.message
              });
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消提现"
          });
        });
    }
  }
};
</script>
<style scoped>
.withdrawal {
  height: 100%;
}
.main .content {
  width: 80%;
  margin: 20px auto;
}
.area {
  border: 1px solid #ebebeb;
  padding: 20px;
  margin-bottom: 20px;
  position: relative;
}
.mod dl {
  margin-left: 30px;
}
.mod dl dt {
  font-size: 18px;
  color: #000;
}
.mod dl dd {
  margin-left: 20px;
}
.mod dl dd span {
  color: #fa8b00;
  font-size: 30px;
  display: inline-block;
  vertical-align: top;
}
.mod dl dd a {
  margin-top: 10px;
  margin-left: 20px;
}
a:link.more,
a:visited.more {
  color: #2aa1f2;
  position: absolute;
  bottom: 20px;
  right: 20px;
}
.mod .btn_ashy_tx {
  display: inline-block;
  padding: 0px 10px;
  height: 28px;
  line-height: 28px;
  color: #666;
  text-align: center;
  border: 1px solid #ebebeb;
}
.attention h5 {
  font-size: 18px;
}
.attention dl {
  margin-top: 20px;
}
.attention dl dt {
  font-size: 16px;
  height: 40px;
  color: #000;
}
.attention dl dd {
  padding-bottom: 10px;
}
</style>
